package net.werup.am.collector;

import java.util.List;

import net.werup.am.collector.dao.UnparsedXMLDao;
import net.werup.am.collector.domain.UnparsedXML;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Agent {

	 /**
	 * @param args
	 */
	public static void main( String[] args )
    {	    	
    	ApplicationContext springContext = new ClassPathXmlApplicationContext( new String[] {"agentContext.xml"});
    	UnparsedXML xml1 = new UnparsedXML();
    	xml1.setName("Test 1");
    	UnparsedXML xml2 = new UnparsedXML();
    	xml2.setName("Test 2");
    	UnparsedXML xml3 = new UnparsedXML();
    	xml3.setName("Test 3");
    	
    	
    	//xml.setId( 1 );
    	UnparsedXMLDao xmlDao = (UnparsedXMLDao) springContext.getBean( "unparsedXMLDao" );
    	xmlDao.save( xml1 );
    	System.out.println( xml1.getId() );
    	xmlDao.save( xml2 );
    	System.out.println( xml2.getId() );
    	xmlDao.save( xml3 );
    	System.out.println( xml3.getId() );
    	
    	xmlDao.flush();
    	
    	UnparsedXML xmlRes = xmlDao.findById( 1 );
    	System.out.println( xmlRes );
    	
    	List entries = xmlDao.findByName( "Test 1" );
    	System.out.println( entries );
    	
    	List entriesAll = xmlDao.findAll();
    	System.out.println( entriesAll );
    	
    }
	    	
}
